<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<script type="text/javascript">
	$(document).ready(function() {
		$('#pageTitle').text('<spring:message code="editCipeproject.heading.view" />');
		
		$("#editCipeprojectForm").validate({
			rules : {
				name : {
					required : false
				}
			}
		});
		$('#loginFormSubmit').click(function() {
		 //alert("hi" +$('#finalManagementFunds').val() );
		 
		  var v1= $('#projectID').val();
		  var v2= $('#acronym').val();
		  var v3=$('#partner\\.id').val();
		  var v4=$('#projectTitle').val();
		  var v5=$('#cipeprojecttype\\.id').val();
		  var v6=$('#programOfficer\\.id').val();
		  var v7=$('#programAssistant\\.id').val();
		  var v8=$('#region\\.id').val();
		  var v9=$('#country\\.id').val();
		  var v10=$('#cipeprojectstatus\\.id').val();
		  var v11=$('#fiscalYear').val();
		  var v12 = $('#initialProjectStartDate').val();
		  var v13 = $('#finalProjectStartDate').val();
		  var v14 = $('#initialProjectEndDate').val();
		  var v15 = $('#finalProjectEndDate').val();
		  var v16 = $('#initialManagementFunds').val();
		  var v17 = $('#finalManagementFunds').val();
		 
		 if(v1!='' || v2!='' || v3!=''|| v4!='' || v5!='' || v6!='' || v7!='' || v8!='' || v9!='' || v10!='' || v11!='' || v12!='' || v13!='' || v14!='' || v15!=''|| v16!=''|| v17!=''){		    
		   return true;
		 }
		 alert("Please enter at least one filter criteria");
		 return false;
		});
		
		$('.edit-cipeproject-link').click(function() {
			loadDiv('content', 'showEditCipeproject.do?id=' + $(this).attr('cipeprojectId'));
		});
		$(function() {
			$("#initialProjectStartDate").datepicker();
		});
		$(function() {
			$("#finalProjectStartDate").datepicker();
		});
		$(function() {
			$("#initialProjectEndDate").datepicker();
		});
		$(function() {
			$("#finalProjectEndDate").datepicker();
		});
	});

	$('.view-knowledgemanagementsearch-link').click(function() {
		loadDiv('content', 'findKnowledgeManagement.do');
	});
	$('.edit-cipeprojectsummary-link').click(function() {
		loadDiv('content', 'showCipeprojectSummary.do?id=' + $(this).attr('cipeprojectId'));
	});
	
	  $('.edit-partnergrant-link').click(function() {
			loadDiv('content', 'showEditPartnergrantView.do?id=' + $(this).attr('cipeprojectId'));
		});
	
	$('.close-button').click(function() {
		loadDiv('content', 'refreshDashboard.do');
     });
   
   /*
	$('#check-all').click(function() {           
          var checkBox = $('#paymentRqst input:checkbox');
          for(var i = 0; i < checkBox.length; i++) {
       	   checkBox[i].checked = this.checked;
          }
   	});*/
</script>
<div id="findCipeprojectDiv">
	<form:form name="editCipeprojectForm" id="editCipeprojectForm" action="findResultCipeproject.do" method="post" modelAttribute="cipeproject">
		<form:hidden path="id" />
		<div class="main_form">
			<div class="form_head">
	    		<a href="#" class="close-button gray_btn floatR">Close Form</a>
	    		<a href="#" class="view-knowledgemanagementsearch-link blue_btn floatR"><spring:message code="findPartnergrant.link.viewKnowledgeManagement" /></a>
	    		<br class="clear" />
	    	</div>
	    	<div class="form_cont">
				<table cellspacing="5" width="100%">

					<tr class="row">
						<td class="input-field" colspan="5">
							<%@ include file="/common/messages.jsp" %>
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.projectID" /></td>
						<td class="input-field">
							<form:input path="projectID" cssClass="input-full-width text_white" />
							<form:errors path="projectID" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.acronym" /></td>
						<td class="input-field">
							<form:input path="acronym" cssClass="input-full-width text_white" />
							<form:errors path="acronym" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.partner" /></td>
						<td class="input-field">
						<form:select path="partner.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${partnerList}" itemValue="id" itemLabel="shortPartnerName" />
							</form:select></td>
							<form:errors path="partner.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.projectTitle" /></td>
						<td class="input-field">
							<form:input path="projectTitle" cssClass="input-full-width text_white" />
							<form:errors path="projectTitle" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.type" /></td>
						<td class="input-field">
							<form:select path="cipeprojecttype.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${cipeprojecttypeList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="cipeprojecttype.id" cssClass="error"/>
						</td>
						<td width="50">&nbsp;</td>
					<!--<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.seniorProgramOfficer" /></td>
						<td class="input-field"><form:select path="seniorProgramOfficer.id">
								<form:options items="${seniorProgramOfficerList}" itemValue="id" itemLabel="fullName" />
							</form:select></td>
						<td><form:errors path="seniorProgramOfficer.id" cssClass="error" /></td>
					</tr>
					-->
						<td class="label"><spring:message code="editCipeproject.label.programOfficer" /></td>
						<td class="input-field">
							<form:select path="programOfficer.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${programOfficerList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="programOfficer.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.programAssistant" /></td>
						<td class="input-field">
							<form:select path="programAssistant.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${programAssistantList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="programAssistant.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.region" /></td>
						<td class="input-field">
							<form:select path="region.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${regionList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="region.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.country" /></td>
						<td class="input-field">
							<form:select path="country.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${countryList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="country.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.status" /></td>
						<td class="input-field">
							<form:select path="cipeprojectstatus.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${cipeprojectstatusList}" itemValue="id" itemLabel="displayName" />
							</form:select></td>
							<form:errors path="cipeprojecttype.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.fiscalYear" /></td>
						<td class="input-field">
							<form:input path="fiscalYear" cssClass="input-full-width text_white" /></td>
							<form:errors path="fiscalYear" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label">&nbsp;</td>
	                	<td></td>
	                </tr>
	                <tr>
						<td class="label"><spring:message code="editCipeproject.label.startDateBetween" /></td>
						<td class="input-field">
							<form:input path="initialProjectStartDate" cssClass="text_white"/>
							<form:errors path="initialProjectStartDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.and" /></td>
						<td class="input-field">
							<form:input path="finalProjectStartDate" cssClass="text_white"/>
							<form:errors path="finalProjectStartDate" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label"><spring:message code="editCipeproject.label.endDateBetween" /></td>
						<td class="input-field">
							<form:input path="initialProjectEndDate" cssClass="input-full-width text_white" />
							<form:errors path="initialProjectEndDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.and" /></td>
						<td class="input-field">
							<form:input path="finalProjectEndDate" cssClass="input-full-width text_white" />
							<form:errors path="finalProjectEndDate" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.managementFundsBetween" /></td>
						<td class="input-field">
							<form:input path="initialManagementFunds" cssClass="input-full-width text_white" />
							<form:errors path="initialManagementFunds" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.and" /></td>
						<td class="input-field">
							<form:input path="finalManagementFunds" cssClass="input-full-width text_white" />
							<form:errors path="finalManagementFunds" cssClass="error" />
						</td>
					</tr>
					<tr>
	                	<td class="label">&nbsp;</td>
	                	<td>&nbsp;</td>
	                	<td width="50">&nbsp;</td>
	                	<td class="label">&nbsp;</td>
	                	<td></td>
	              	</tr>
					<tr class="row">
						<td class="input-field" align="center" colspan="5">
							<sj:submit id="loginFormSubmit" cssClass="blue_btn" target="findCipeprojectDiv" key="findCipeproject.button.search" validate="true" tabindex="-1"/>
							<input type="reset" class="blue_btn" value="<spring:message code='findCipeproject.button.reset' />" tabindex="-1"/>
						</td>
					</tr>
				</table>
				<div id="cipeprojectListDiv" class="hastable" style="overflow: auto">
					<table class="tablesorter">
				<c:choose>
					<c:when test="${ !empty cipeprojectList}">
								<thead>
									<c:if test="${messgae!='null'}">
									<tr>
									<th colspan="12"><font size="4"><c:out value="${message}"></c:out></font></th>
									</tr>
									</c:if>
									
									<tr>
									  <!--th><spring:message code="common.select.all"/>&#10;<input type="checkbox" id="check-all"></th-->
										<th><spring:message code="cipeprojectlist.table.heading.projectID" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.acronym" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.projectSponsor" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.projectTitle" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.type" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.programOfficer" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.programAssistant" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.region" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.country" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.status" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.startDate" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.endDate" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.managementFunds" /></th>
										<%--<th><spring:message code="cipeprojectlist.table.link.viewProject" /></th> --%>
									</tr>
								</thead>
								<tbody id="paymentRqst">
									<c:forEach items="${cipeprojectList}" var="cipeproject">
									<tr>
										<!--td><input type="checkbox" name="check_element" value="${cipeproject.id}"></td-->
											<td>
											     <c:if test="${cipeproject.cipeprojecttype.displayName=='Partner'}">
												 <a href="javascript://" class="edit-partnergrant-link" cipeprojectId="${cipeproject.id}">${cipeproject.projectID}</a>
											   </c:if>
											   <c:if test="${cipeproject.cipeprojecttype.displayName!='Partner'}">												
												 <a href="javascript://" class="edit-cipeprojectsummary-link" cipeprojectId="${cipeproject.id}">${cipeproject.projectID}</a>
											   </c:if> 
											</td>
											<td>${cipeproject.acronym}</td>
											<td>${cipeproject.partner.partnerName}</td>
											<td>${cipeproject.projectTitle}</td>
											<td>${cipeproject.cipeprojecttype.displayName}</td>
											<td>${cipeproject.programOfficer.fullName}</td>
											<td>${cipeproject.programAssistant.fullName}</td>
											<td>${cipeproject.region.displayName}</td>
											<td>${cipeproject.country.displayName}</td>
											<td>${cipeproject.cipeprojectstatus.displayName}</td>
											<td><fmt:formatDate pattern="MM-dd-yyyy" value="${cipeproject.projectStartDate}" /></td>
											<td><fmt:formatDate pattern="MM-dd-yyyy" value="${cipeproject.projectEndDate}" /></td>
											<td>${cipeproject.managementFunds}</td>
											<%--<td><a href="javascript://" class="edit-cipeprojectsummary-link" cipeprojectId="${cipeproject.id}"><spring:message code="label.view" /></a></td>
											<td><a href="javascript://" class="edit-cipeproject-link" cipeprojectId="${cipeproject.id}"><spring:message code="cipeprojectlist.table.link.edit" /></a></td> --%>
										</tr>
									</c:forEach>					
										<!--tr align="center"><td colspan="14" align="left"><input type="button" class="blue_btn" name="view" value="View Selected Projects" align="center"></td></tr-->
									</c:when>
								<c:otherwise>
								<c:if test="${ !empty param.action}">					  
								   <tr><td colspan="14"> Your query has returned 0 records </td></tr>
								 </c:if>  
								</c:otherwise>
						    </c:choose>		
				
						</tbody>
					</table>
					<div id="cipeprojectListPager"></div>
				</div>
			</div>
		</div>				
	</form:form>
</div>